import { h } from "../../lib/guide-coco-mini-vue.esm.js";

export default {
	name: "Child",
	setup(props, { emit }) {
		return {
			emitChangeAge: () => {
				console.log("触发了 修改年龄");
				emit("changeAge", 18);
			},
			emitChangeNames: () => {
				console.log("触发了 修改用户名");
				emit("change-name", "张三", "李四");
			}
		}
	},
	render() {
		return h("div", { style: "border: 1px solid green;" }, [
			h("p", {}, '我是子节点,我的数据来自父节点'),
			h("p", {}, `数据：用户列表：${this.names}-------年龄：${this.age}`),
			h("button", {
				onClick: this.emitChangeAge,
			}, "修改年龄"),
			h("button", {
				onClick: this.emitChangeNames,
			}, "修改用户名"),
		]);
	},
};
